﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using RegisterationCommon.Common;
using System.Data;
using RegisterationCommon.Student;

namespace RegisterationSystem.Space_Education
{
    public partial class sys_log : System.Web.UI.Page
    {
        public string ShcJson = "";
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Request.Form["action"] != "")
                {
                    switch (Request.Form["action"])
                    {
                        case "delstudentlist":
                            DelStudentList();
                            break;
                        case "delstudentByID":
                            DelStudentByID();
                            break;
                    }
                }
                ShcJson = BaseLibrary.GetSclJson();
                Bind();
            }
        }
        //日志类型
        void Bind()
        {
            DataTable dt = DBAction.GetDTFromSQL("select TypeName from Sys_Log group by TypeName");
            DataRow[] drs = dt.Select();
            dllTypeName.DataTextField = "TypeName";
            dllTypeName.DataValueField = "TypeName";
            dllTypeName.DataSource = dt;
            dllTypeName.DataBind();
            dllTypeName.Items.Insert(0, new ListItem("全部", "全部"));
        }
        //根据ID删除
        void DelStudentByID()
        {
            int id =Convert.ToInt32(Request.Form["id"].ToString());
            RParams RP = new RParams();
            RP.Add("LogId", id, SqlDbType.Int);
            string whereFields = "LogId=@LogId";
            DBAction.Delete(ETableName.Sys_Log, whereFields, RP);
        }
        //批量删除
        void DelStudentList()
        {
            //获删除改ID
            string idlist = Request.Form["id"];
            string[] ids = idlist.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
            for (int i = 0; i < ids.Length; i++)
            {
                if (!string.IsNullOrEmpty(ids[i].Trim()))
                {
                    RParams RP = new RParams();
                    RP.Add("LogId", Convert.ToInt32(ids[i].ToString()), SqlDbType.Int);
                    string whereFields = "LogId=@LogId";
                    DBAction.Delete(ETableName.Sys_Log, whereFields, RP);
                }
            }
        }
    }
}